<?php

/**
 * Cliente form base class.
 *
 * @method Cliente getObject() Returns the current form's model object
 *
 * @package    saveenergy
 * @subpackage form
 * @author     0
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseClienteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'cif'             => new sfWidgetFormInputText(),
      'comercial_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Comercial'), 'add_empty' => false)),
      'nombre'          => new sfWidgetFormInputText(),
      'apellido1'       => new sfWidgetFormInputText(),
      'apellido2'       => new sfWidgetFormInputText(),
      'direccion'       => new sfWidgetFormInputText(),
      'cp'              => new sfWidgetFormInputText(),
      'telefono'        => new sfWidgetFormInputText(),
      'email'           => new sfWidgetFormInputText(),
      'responsable'     => new sfWidgetFormInputText(),
      'numeroCuenta'    => new sfWidgetFormInputText(),
      'supercliente'    => new sfWidgetFormInputText(),
      'is_supercliente' => new sfWidgetFormInputCheckbox(),
      'cnae'            => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'cif'             => new sfValidatorInteger(),
      'comercial_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Comercial'))),
      'nombre'          => new sfValidatorString(array('max_length' => 40)),
      'apellido1'       => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'apellido2'       => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'direccion'       => new sfValidatorString(array('max_length' => 255)),
      'cp'              => new sfValidatorPass(array('required' => false)),
      'telefono'        => new sfValidatorPass(),
      'email'           => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'responsable'     => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'numeroCuenta'    => new sfValidatorPass(array('required' => false)),
      'supercliente'    => new sfValidatorPass(array('required' => false)),
      'is_supercliente' => new sfValidatorBoolean(array('required' => false)),
      'cnae'            => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Cliente', 'column' => array('cif')))
    );

    $this->widgetSchema->setNameFormat('cliente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Cliente';
  }

}
